package com.kyh.controller.api.sys;

import java.io.BufferedReader;
import java.util.Enumeration;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.kyh.mapper.CommonMapper;
import com.kyh.util.AESUtil;
import com.kyh.vo.R;

@Controller
@RequestMapping("/api/outer/demo")
public class ApiDemoController {
	
	private static final Logger logger = Logger.getLogger(ApiDemoController.class);

	@Autowired
	private CommonMapper commonMapper;
	
	
	@RequestMapping("/test")
	@ResponseBody
	public R test(
			HttpServletRequest request,
			HttpServletResponse response,
			String account
			) throws Exception {

		logger.info("----------test--------------------");
		Enumeration<String> reqNames = request.getParameterNames();
		for (; reqNames.hasMoreElements();) {
			String name = reqNames.nextElement();
			logger.info(name + "=====" + request.getParameter(name));
		}
		logger.info("----------test--------------------");
		
		String inputLine;
		String str = "";
		
		BufferedReader br = null;
		try {
			br = request.getReader();
			while ((inputLine = br.readLine()) != null) {
				str += inputLine;
			}
			br.close();
		} catch (Exception e) {
			System.out.println("IOException: " + e);
		}
		System.out.println("str:" + str);
		logger.info("----------test--------------------");

		
		
		return R.ok();
	}
	
	public static void main(String[] args) {
		String[] cardnos = new String[]{
			"998PuFZvhf4W9Ozz9pRzocA2174FUkzhmxyJeqQM1XM=",
			"BtzTDxcigLmzF0v29+BPGsA2174FUkzhmxyJeqQM1XM=",
			"vjuJr/AmAWgY0DOPBDjURMA2174FUkzhmxyJeqQM1XM=",
			"7XDIf9VVwNm6G0kIDFpoFsA2174FUkzhmxyJeqQM1XM=",
			"Ohk2WtibnjVuoEoNR+Q0vsA2174FUkzhmxyJeqQM1XM=",
			"PxY1PVI3ZHqk+HAPt9astMA2174FUkzhmxyJeqQM1XM=",
			"jg/a70IFTCaOaBCB8nCi1sA2174FUkzhmxyJeqQM1XM=",
			"wwCujNOyD8ON/KY9HqFUKMA2174FUkzhmxyJeqQM1XM=",
			"kUtlBfWzPLGYn6HNiJK42sA2174FUkzhmxyJeqQM1XM="
			
		};
		
		for (String encrypt : cardnos) {
			String cardNo = AESUtil.aesDecrypt(encrypt);
			System.out.println(cardNo);
		}
	}
	
}
